//
// Created by 11510 on 2024/6/23.
//

#ifndef TEXTQUERY_TEXTQUERY_H
#define TEXTQUERY_TEXTQUERY_H

#include <iostream>
#include <memory>
#include <vector>
#include <set>
#include <map>
#include "QueryResult.h"
using std::ifstream;
using std::vector;
using std::map;
using std::set;
using std::string;
using std::shared_ptr;

class QueryResult; // 声明返回类型类

class TextQuery {
public:
    /* size_t */
    using line_no = vector<string>::size_type;

    TextQuery(ifstream &);

    QueryResult query(const string &) const;

private:
    shared_ptr<vector<string>> file; /* 存储输入文件的每一行 */

    // 每个单词对应出现的行号的集合
    map<string, shared_ptr<set<line_no>>> wm;
};


#endif //TEXTQUERY_TEXTQUERY_H
